<?php
$tools = array(
		n_href(n_url('nconfig', 'index'), '返回', 'class="n-href" target="_self"'),
	);
echo n_mod('skin')->pageHead('数据项列表', $tools);
?>
<div class="n-row n-margin-top n-margin-bottom">
	<label class="n-col-9 n-nopadding" style="text-align:center">本规则有<?=count($data['data'])?>个数据项</label>
	<div class="n-col-3 n-nopadding">
		<button class="a-button-green">
			<a target="_self" href="<?=n_url('nconfig', 'itemCreate', array('main_id' => $data['main_id'])) ?>">
				<i class="fa fa-plus" style="display:block;color:#fff;"></i>
			</a>
		</button>
	</div>
</div>
<table class="a-table a-table-striped">
	<thead>
		<tr>
			<th style="width:20%">名称</th>
			<th style="width:10%">类型</th>
			<th style="width:20%">单位</th>
			<th style="width:30%">可选项</th>
			<th style="width:10%">默认</th>
			<th style="width:10%">操作</th>
		</tr>
	</thead>
	<tbody>
	<?php
	$api = n_api("nconfig");
	if (! empty($data['data'])) :
		foreach ($data['data'] as $key => $val) :
			$target = 'class="n-href" target="_self"';
			$args = array('id' => $val['id'], 'main_id' => $data['main_id']);
			$url = n_url('nconfig', 'itemEdit', $args);
			$edit = n_href($url, '<i class="fa fa-edit"></i>', $target);
			$url = n_url('nconfig', 'itemDel', $args);
			$remove = n_href($url, '<i class="fa fa-remove"></i>', $target);
			$link = "$edit $remove";
	?>
	<tr>
		<td><?=$val['name']?></td>
		<td><?=$api->type[$val['itype']]?></td>
		<td><?=$val['unit']?></td>
		<td><?=in_array($val['itype'], array(10, 11)) ? $val['option'] : '无'?></td>
		<td><?=$val['default']?></td>
		<td><?=$link?></td>
	</tr>
	<?php
		endforeach;
	else :
	?>
	<tr>
		<td colspan="6">暂无数据</td>
	</tr>	
	<?php
	endif;
	?>
	</tbody>
</table>		
